import json
import random

#读取 json文件
with open('F:\dataset\cook\\tran_dataset_single_0.json','r',encoding='utf-8') as file :
    data = json.load(file)

n = len(data) // 20
sampled_data = random.sample(data,n)
with open('data/split_data.json','w',encoding='utf-8') as file:
    json.dump(sampled_data,file,indent=4)
print(len(data))

# with open('data/split_data.json','r',encoding='utf-8') as file:
#     data = json.load(file)
# print(len(data))